<script>
	$(function(){
		Namespace.register("EBCMS.{$namespace}temp");
		EBCMS.{$namespace}temp.push = function push(){
			EBCMS.CORE.submit({
				url:'{:U('push')}',
				form:'{$namespace}temp_Push_Form',
				success:function(data){
					EBCMS.MSG.tips(data.info);
					$('#lgModal').modal('toggle');
				}
			});
		};
		EBCMS.FN.renderPic('#{$namespace}tempPushthumb');
	});
</script>
<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	<h4 class="modal-title">推送服务</h4>
</div>
<div class="modal-body">
	<form class="form-horizontal" id="{$namespace}temp_Push_Form">
		<div class="row">
			<div class="col-md-4">
				<h5 class="text-warning"><b><span class="glyphicon glyphicon-phone-alt"></span> 推荐到</b></h5>
				<hr>
				<div id="{$namespace}temp_recommendtypecontainer"></div>
			</div>
			<div class="col-md-8">
				<h5 class="text-warning"><b><span class="glyphicon glyphicon-phone-alt"></span> 推荐内容</b></h5>
				<hr>
				<div class="form-group">
					<label for="{$namespace}tempPushtitle" class="col-sm-2 control-label">标题</label>
					<div class="col-sm-10">
						<input type="text" name="title" value="{$title}" class="form-control" id="{$namespace}tempPushtitle" placeholder="标题">
					</div>
				</div>
				<div class="form-group">
					<label for="{$namespace}tempPushurl" class="col-sm-2 control-label">链接</label>
					<div class="col-sm-10">
						<input type="text" name="url" value="{$url}" class="form-control" id="{$namespace}tempPushurl" placeholder="请参考U函数的写法">
					</div>
				</div>
				<div class="form-group">
					<label for="{$namespace}tempPushdescription" class="col-sm-2 control-label">简介</label>
					<div class="col-sm-10">
						<textarea class="form-control" name="description" rows="5" id="{$namespace}tempPushdescription" placeholder="一般不要超过250个字符">{$description}</textarea>
					</div>
				</div>
				<div class="form-group">
					<label for="{$namespace}tempPushthumb" class="col-sm-2 control-label">缩略图</label>
					<div class="col-sm-8">
						<input type="text" name="thumb" value="{$thumb}" class="form-control" id="{$namespace}tempPushthumb" placeholder="">
					</div>
					<div class="col-sm-2">
						<div id="{$namespace}tempPushthumbPicker" style="width:100%;height:20px;" onmouseover="$(this).resize();">上传</div>
					</div>
				</div>
				<div class="form-group">
					<label for="{$namespace}tempPushsort" class="col-sm-2 control-label">排序</label>
					<div class="col-sm-10">
						<input type="number" min="1" max="99" name="sort" value="{$sort}" class="form-control" id="{$namespace}tempPushsort" placeholder="">
					</div>
				</div>
				<input type="hidden" name="content_id" value="{$id}">
				<input type="hidden" name="moduletype" value="{:I('moduletype')}">
			</div>
		</div>
	</form>
</div>
<div class="modal-footer">
	<button type="button" class="btn btn-success" onclick="EBCMS.{$namespace}temp.push();">提交</button>
	<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
</div>
<script>
	$(function(){
		EBCMS.{$namespace}temp.recommendtyperefresh = function recommendtyperefresh(){
			EBCMS.CORE.load({
				url:'{:U('push')}',
				queryParams:{
					__type:'getrecommendtype',
					moduletype:'{:I('moduletype')}',
					content_id:'{:I('id')}',
				},
				tpl:'{$namespace}temp-recommendtype-table',
				target:'#{$namespace}temp_recommendtypecontainer',
			});
		};
		EBCMS.{$namespace}temp.recommendtyperefresh();
	});
</script>
<script id="{$namespace}temp-recommendtype-table" type="text/html">
	<ul class="list-group tree tree_first" style="border-top: 1px solid #ddd;border-right: 1px solid #ddd;border-bottom: 1px solid #ddd;">
		{{include '{$namespace}temp-recommendtype-table-item' v}}
	</ul>
</script>
<script id="{$namespace}temp-recommendtype-table-item" type="text/html">
	{{each rows as v n}}
		{{if v.rows}}
			<li class="list-group-item">
				<span class="badge">{{v.mark}}</span>
				<label>{{v.title}}</label>
			</li>
			<li class="list-group-item nopadding">
				<ul class="list-group tree">
					{{include '{$namespace}temp-recommendtype-table-item' v}}
				</ul>
			</li>
		{{else}}
			<li class="list-group-item">
				<span class="badge">{{v.mark}}</span>
				<input type="checkbox" name="category_ids[]" value="{{v.id}}" id="{$namespace}temp-recommendtype-table-item-{{v.id}}" {{if v.checked}}checked{{/if}}>
				<label for='{$namespace}temp-recommendtype-table-item-{{v.id}}'>{{v.title}}</label>
			</li>
		{{/if}}
	{{/each}}
</script>